string s = "aeiou";
bool fun(vector<int>& nums1) {
    for (int i = 0; i < 5; i++) {
        if (nums1[s[i] - 'a'] == 0)
            return false;
    }
    return true;
}
class Solution {
public:
    long long countOfSubstrings(string word, int k) {
        int n = word.size(), left1 = 0, left2 = 0, right = 0, cnt1 = 0,
            cnt2 = 0;
        long long ans = 0;
        vector<int> nums1(26), nums2(26);
        auto check = [](char c) {
            return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
        };
        auto check1 = [&]() {
            // 走到成功
            if(k < cnt1) return true;
            // if(fun(nums1) && k < cnt1)
            //      return true;
            return false;
        };
        auto check2 = [&]() {
            // 无意义走
            if (left1 > left2)
                return true;
            if(fun(nums2) && cnt2 == k){
                return true;
            }
            return false;
            // if (k > cnt2 || (!fun(nums2)))
            //     return false;
            // if (k != cnt2 || (!fun(nums2)))
            //     return false;
            // // 走到成功
            // return true;
        };
        for (; right < n; right++) {
            nums1[word[right] - 'a']++;
            nums2[word[right] - 'a']++;
            if (!check(word[right]))
                cnt1++, cnt2++;

            while (check1()) {
                nums1[word[left1] - 'a']--;
                if (!check(word[left1]))
                    cnt1--;
                left1++;
            }
            while (check2()) {
                nums2[word[left2] - 'a']--;
                if (!check(word[left2]))
                    cnt2--;
                left2++;
            }
            ans += max(0,(left2 - left1));
            // cout << left1 << ' ' << left2 << ' ' << right << endl;
            // cout << cnt1 <<' ' << cnt2 << endl;
        }
        return ans;
    }
};